//
//  ListViewController.m
//  CookDemo
//
//  Created by lanou3g on 15/8/30.
//  Copyright (c) 2015年 DTR. All rights reserved.
//

#import "ListViewController.h"
#import "ListTableViewCell.h"
#import "KitchenManager.h"
#import "Kitchen.h"
#import "SingleViewController.h"

@interface ListViewController ()

@property (weak, nonatomic) IBOutlet UITableView *ListTableView;

@end

@implementation ListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
//    [[KitchenManager defaultManager]GetPopularDetailsInfoCOmplete:^{
//        [self.ListTableView reloadData];
//        PopularDetailsInfo *arr=[[KitchenManager defaultManager].popularDetailsList lastObject];
//        NSLog(@"%@",arr.name);
//    }];
    
}

- (void) viewWillAppear:(BOOL)animated {
    [[KitchenManager defaultManager]GetPopularDetailsInfoCOmplete:^{
        
        self.arr=[KitchenManager defaultManager].popularDetailsInfo.sample_recipes;
        [self.ListTableView   reloadData];
    }];
    
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.arr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    ListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"listCell" forIndexPath:indexPath];
    PopularDetailsInfo *p = [[KitchenManager defaultManager].popularDetailsList lastObject];
    [cell  setCellWithPopularDetailsInfo:p AtIndexPath:indexPath.row];
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    SingleViewController *SIngleVC = [[SingleViewController alloc]init];
    
   // [self showViewController:SIngleVC sender:@"123"];
    
//    [self performSegueWithIdentifier:@"DetialID" sender:nil];
    
    
    
}


#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
//- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
//    SingleViewController *singleVC = segue.destinationViewController;
//    singleVC.indexPath = sender;
    
//}


@end
